package com.ktgj.customer.domain.Insurance.dftModel;
public class EncException
        extends Exception
{
    private int id;
    private String classname;
    private String method;
    private String message;
    private EncException previous = null;
    private String separator = "\n";

    public String getMessage()
    {
        return this.message;
    }

    public EncException(int id, String classname, String method, String message, EncException previous)
    {
        this.id = id;
        this.classname = classname;
        this.method = method;
        this.message = message;
        this.previous = previous;
    }

    public String traceBack()
    {
        return traceBack("\n");
    }

    public String traceBack(String sep)
    {
        this.separator = sep;
        int level = 0;
        EncException e = this;
        String text = line("Calling sequence (top to bottom)");
        while (e != null)
        {
            level++;
            text = text + line(new StringBuilder("--level ").append(level).append("--------------------------------------").toString());
            text = text + line(new StringBuilder("Class/Method: ").append(e.classname).append("/").append(e.method).toString());
            text = text + line(new StringBuilder("Id          : ").append(e.id).toString());
            text = text + line(new StringBuilder("Message     : ").append(e.message).toString());
            e = e.previous;
        }
        return text;
    }

    private String line(String s)
    {
        return s + this.separator;
    }
}
